<?php
namespace Album\Model;

use Zend\InputFilter\InputFilterInterface;
use Zend\InputFilter\Factory as InputFactory;
use Zend\InputFilter\InputFilter;
/**
 * 专辑数据库模型
 * @author 李福强
 *
 */
class Album
{
	public $id;
	public $artist;
	public $title;
	protected $inputFilter;
	
	public function exchangeArray($data)
	{
		$this->id = (isset($data['id'])) ? $data['id'] : null;
		$this->artist = (isset($data['artist'])) ? $data['artist'] : null;
		$this->title = (isset($data['title'])) ? $data['title'] : null;		
	}
	
	public function setInputFilter(InputFilterInterface $inputFilter)
	{
		throw new \Exception("Not used");
	}
	
	public function getInputFilter()
	{
		if(!$this->inputFilter) {
			$inputFilter = new InputFilter();
			$factory = new InputFactory();
			
			$inputFilter->add($factory->createInput(array(
			    'name' => 'id',
			    'required' => true,
			    'filters' => array(
			        array('name' => 'Int'),
			    ),
			)));
			$inputFilter->add($factory->createInput(array(
			    'name' => 'artist',
			    'required' => true,
			    'filters' => array(
			        array('name' => 'StripTags'),
			        array('name' => 'StringTrim'),
			    ),
			    'validators' => array(
			        array(
			            'name' => 'StringLength',
			            'options' => array(
			                'encoding' => 'UTF-8',
			                'min' => 1,
			                'max' => 100,
			            ),  
			        ),
			    ),
			)));
			
			$inputFilter->add($factory->createInput(array(
			    'name' => 'title',
			    'required' => true,
			    'filters' => array(
			        array('name' => 'StripTags'),
			        array('name' => 'StringTrim'),
			    ),
			    'validators' => array(
			        array(
			            'name' => 'StringLength',
			            'options' => array(
			                'encoding' => 'UTF-8',
			                'min' => 1,
			                'max' => 100,
			            ),
			        ),
			    ),			    
			)));
			
			$this->inputFilter = $inputFilter;
		}
		return $this->inputFilter;
	}
	
	public function getArrayCopy()
	{
		return get_object_vars($this);
	}
	
	
	
	
	
	
	
	
	
	
}
?>